<?php
    //tool buttons
	$tool_buttons = array
	(
		'list' => array
		(
			'image'=>'btnListLarge.gif', 
			'text'=>ucfirst(LANG_ROLES).': '.LANG_LIST, 
			'url'=>'/roles'
		),
		'add_button' => array
		(
			'image'=>'btnEditLarge.gif', 
			'text'=>ucfirst(LANG_ROLE).': '.LANG_EDIT, 
			'url'=>'/roles/edit/'.$this->data[role][id]
		)
	);
	
	//header
	$this->helpers->htmlx->MenuText1(LANG_SYSTEM_ACCESS.': '.LANG_EDIT.' '.LANG_FOR.' "'.$this->data['role']['name'].'"', "edit.gif");
	
	//toolbar
	$this->helpers->toolbars->Toolbar($tool_buttons);
	
	//form
	XHTML::Form('/'.$this->name.'/edit/'.$this->data['role_id']);
	
	echo "<table class='grid' cellspacing = '1'>";
	
	    //header row
	   	echo "<tr class = 'ui-widget-header'>";
			$this->helpers->htmlx->td(ucfirst(LANG_TABLE_NAME), ' class = "gridHeader" style = "padding: 3px; " ');
			$this->helpers->htmlx->td(ucfirst(LANG_LIST), ' class = "gridHeader" style = "padding: 3px; " align = "center"');	  	
			$this->helpers->htmlx->td(ucfirst(LANG_ADD), ' class = "gridHeader" style = "padding: 3px; " align = "center"');
			$this->helpers->htmlx->td(ucfirst(LANG_VIEW), ' class = "gridHeader" style = "padding: 3px; " align = "center"');
			$this->helpers->htmlx->td(ucfirst(LANG_EDIT), ' class = "gridHeader" style = "padding: 3px; " align = "center"');
			$this->helpers->htmlx->td(ucfirst(LANG_DELETE), ' class = "gridHeader" style = "padding: 3px; " align = "center"');
		echo "</tr>";
		
    	$i = 1;
    	foreach ($this->data['accesses'] as $access)
    	{
    	    $cellStyle = 'gridCell';

	    	echo "<tr>";
	    	
	    	    //table name
	    	    echo "<td class='$cellStyle' align='left'>";
	    		    echo Language::Get(str_replace('LANG_', '', $access['table_name']), 'CAPITALIZE').' ';
	    		    XHTML::Anchor('/system_permissions_columns/edit/'.$this->data['role_id'].'/'. $access['system_table_id'], "[columns]", array('style' => 'color: #3491C7; '));
	    		echo "</td>";
	    		
	    		//list access
	    		echo "<td class='$cellStyle' align='center'>";
	    			XHTML::InputCheckbox('access['.$access[id].'][access_list]', 1, $access['access_list']);   		
	    		echo "</td>";
	    		 
	    		//add access
	    		echo "<td class='$cellStyle' align='center'>";
	    			XHTML::InputCheckbox('access['.$access[id].'][add]', 1, $access['add']);   		
	    		echo "</td>";  
	    		
	    		//view access
	    		echo "<td class='$cellStyle' align='center'>";
	    			XHTML::InputCheckbox('access['.$access[id].'][view]', 1, $access['view'], 'id = "view'.$access['id'].'" onclick = "document.getElementById(\'edit'.$access['id'].'\').checked = false"');   		
	    		echo "</td>"; 
	    		 
	    		//edit access
	    		echo "<td class='$cellStyle' align='center'>";
	    			XHTML::InputCheckbox('access['.$access[id].'][edit]', 1, $access['edit'], 'id = "edit'.$access['id'].'" onclick = "document.getElementById(\'view'.$access['id'].'\').checked = true"');   		
	    		echo "</td>"; 
	    		 
	    		//delete access
	    		echo "<td class='$cellStyle' align='center'>";
	    			XHTML::InputCheckbox('access['.$access[id].'][delete]', 1, $access['delete']);   		
	    		echo "</td>";
	    		
	    		XHTML::InputHidden('access['.$access[id].'][id]', $access['id']);
	    		  
	    	echo "</tr>";
	    	$i++;
	    }
	echo "</table>";
	
	$this->helpers->htmlx->SubmitTable('submit','roles/edit/'.$this->data['role_id']);
	echo "</form>";
?>